import Axios from 'axios';

const http = Axios.create({
  baseURL: '/api',
});

// http.interceptors.request.use(config => {
//   config.cancelToken = new Axios.CancelToken(c => { http.cancel = c; })
//   return config;
// });

http.interceptors.response.use(response => {
  if (response.data) return response.data;
  return response;
});

// 把原型上的构造函数放在实例上，方便直接从实例引用
http.CancelToken = Axios.CancelToken;

export default http;
